package leetcode;

import java.util.PriorityQueue;

public class Lc3066 {

    public int minOperations(int[] nums, int k) {
        int cnt = 0;
        PriorityQueue<Long> pq = new PriorityQueue<>();
        for (int i = 0; i < nums.length; i++) {
            pq.offer((long) nums[i]);
        }
        while (pq.peek() < k) {
            long x = pq.poll();
            long y = pq.poll();
            pq.offer(x * 2 + y);
            cnt++;
        }
        return cnt;
    }


}
